package org.apache.commons.httpclient.protocol;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.httpclient.util.LangUtils;

public class Protocol
{
  private static final Map PROTOCOLS = Collections.synchronizedMap(new HashMap());
  private int defaultPort;
  private String scheme;
  private boolean secure;
  private ProtocolSocketFactory socketFactory;

  public Protocol(String paramString, ProtocolSocketFactory paramProtocolSocketFactory, int paramInt)
  {
    if (paramString == null)
      throw new IllegalArgumentException("scheme is null");
    if (paramProtocolSocketFactory == null)
      throw new IllegalArgumentException("socketFactory is null");
    if (paramInt <= 0)
      throw new IllegalArgumentException("port is invalid: " + paramInt);
    this.scheme = paramString;
    this.socketFactory = paramProtocolSocketFactory;
    this.defaultPort = paramInt;
    this.secure = paramProtocolSocketFactory instanceof SecureProtocolSocketFactory;
  }

  public Protocol(String paramString, SecureProtocolSocketFactory paramSecureProtocolSocketFactory, int paramInt)
  {
    this(paramString, paramSecureProtocolSocketFactory, paramInt);
  }

  public static Protocol getProtocol(String paramString)
    throws IllegalStateException
  {
    if (paramString == null)
      throw new IllegalArgumentException("id is null");
    Protocol localProtocol = (Protocol)PROTOCOLS.get(paramString);
    if (localProtocol == null)
      localProtocol = lazyRegisterProtocol(paramString);
    return localProtocol;
  }

  private static Protocol lazyRegisterProtocol(String paramString)
    throws IllegalStateException
  {
    Protocol localProtocol1;
    if ("http".equals(paramString))
    {
      localProtocol1 = new Protocol("http", DefaultProtocolSocketFactory.getSocketFactory(), 80);
      registerProtocol("http", localProtocol1);
    }
    Protocol localProtocol2;
    for (Object localObject = localProtocol1; ; localObject = localProtocol2)
    {
      return localObject;
      if (!("https".equals(paramString)))
        break;
      localProtocol2 = new Protocol("https", SSLProtocolSocketFactory.getSocketFactory(), 443);
      registerProtocol("https", localProtocol2);
    }
    throw new IllegalStateException("unsupported protocol: '" + paramString + "'");
  }

  public static void registerProtocol(String paramString, Protocol paramProtocol)
  {
    if (paramString == null)
      throw new IllegalArgumentException("id is null");
    if (paramProtocol == null)
      throw new IllegalArgumentException("protocol is null");
    PROTOCOLS.put(paramString, paramProtocol);
  }

  public static void unregisterProtocol(String paramString)
  {
    if (paramString == null)
      throw new IllegalArgumentException("id is null");
    PROTOCOLS.remove(paramString);
  }

  public boolean equals(Object paramObject)
  {
    if (paramObject instanceof Protocol)
    {
      Protocol localProtocol = (Protocol)paramObject;
      if ((this.defaultPort != localProtocol.getDefaultPort()) || (!(this.scheme.equalsIgnoreCase(localProtocol.getScheme()))) || (this.secure != localProtocol.isSecure()) || (!(this.socketFactory.equals(localProtocol.getSocketFactory()))));
    }
    for (int i = 1; ; i = 0)
      while (true)
      {
        return i;
        i = 0;
      }
  }

  public int getDefaultPort()
  {
    return this.defaultPort;
  }

  public String getScheme()
  {
    return this.scheme;
  }

  public ProtocolSocketFactory getSocketFactory()
  {
    return this.socketFactory;
  }

  public int hashCode()
  {
    return LangUtils.hashCode(LangUtils.hashCode(LangUtils.hashCode(LangUtils.hashCode(17, this.defaultPort), this.scheme.toLowerCase()), this.secure), this.socketFactory);
  }

  public boolean isSecure()
  {
    return this.secure;
  }

  public int resolvePort(int paramInt)
  {
    if (paramInt <= 0);
    for (int i = getDefaultPort(); ; i = paramInt)
      return i;
  }

  public String toString()
  {
    return this.scheme + ":" + this.defaultPort;
  }
}

/* Location:           E:\Desktop\Android\wordstd\classes_dex2jar.jar
 * Qualified Name:     org.apache.commons.httpclient.protocol.Protocol
 * JD-Core Version:    0.5.3
 */